<script lang="ts" setup>
import type { VxeGridListeners, VxeTableGridOptions } from '#/adapter/vxe-table'

import { h, onMounted, onUnmounted, ref, watch } from 'vue'

import { Page, useVbenModal } from '@vben/common-ui'

import { useDebounceFn } from '@vueuse/core'
import { Modal as AntModal, Button, message, Popconfirm, Space, Spin, Tag } from 'ant-design-vue'

import fileManage from '#/adapter/component/FileManage/index.vue'
import { useVbenVxeGrid } from '#/adapter/vxe-table'
import { allIndex, getFactoryIndex, getTreeAll } from '#/api/goods/scmGoods'
import { approval, getGoodsPurchaseList, getWareHouse, markComplete, markStop } from '#/api/goodsPurchase'
import { timeCategoryAllIndex } from '#/api/goodsPurchaseDetail'
import { requestClient } from '#/api/request'
import { completeCategoryPaths, completePaths } from '#/utils'

import againstDialog from './modules/againstDialog.vue'
import deleteDialog from './modules/deleteDialog.vue'
import exportContract from './modules/exportContract.vue'
import popupForm from './modules/popupForm.vue'

async function fetchgetFactoryIndex({ keyword = '' }: Record<string, any>) {
  const { list } = await getFactoryIndex({
    quick_search: keyword,
    page: 1,
    limit: 999,
    initKey: 'id',
    initValue: undefined,
    select: true,
  })
  return list.map((item: any) => ({
    label: item.SupplyNa,
    value: item.id,
  }))
}
async function fetgetWareHouse({ keyword = '' }: Record<string, any>) {
  const { list } = await getWareHouse({
    quick_search: keyword,
    page: 1,
    limit: 999,
    initKey: 'id',
    initValue: undefined,
    select: true,
  })
  return list.map((item: any) => ({
    label: item.WarehouseName,
    value: item.id,
  }))
}

const keyword4 = ref('')
const keyword = ref('')
const categoryOptions = ref([]) // 货品分类树
const timeCategoryOptions = ref([]) // 时间
const fetching = ref(false)

const formOptions: any = {
  collapsed: true,
  submitOnChange: false,
  // 按下回车时是否提交表单
  submitOnEnter: true,
  wrapperClass: 'grid-cols-5',
  layout: 'horizontal',
  schema: [
    {
      component: 'Cascader',
      fieldName: 'category',
      label: '货品分类',
      componentProps: {
        options: categoryOptions,
        placeholder: '请选择',
        showSearch: true,
        allowClear: true,
        multiple: true,
      },
      operator: '123',
    },
    {
      component: 'Cascader',
      fieldName: 'time_category',
      label: '时间分类',
      operator: '123',
      componentProps: {
        options: timeCategoryOptions,
        placeholder: '时间分类',
        showSearch: true,
        allowClear: true,
        multiple: true,
      },
    },
    {
      component: 'Input',
      componentProps: {
        placeholder: '模糊搜索',
        allowClear: true,
      },
      fieldName: 'goods_purchase_sn',
      label: '采购单号',
      operator: 'LIKE',
    },
    {
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '模糊搜索',
      },
      fieldName: 'goods_no',
      label: '货号',
      operator: 'false',
    },
    {
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '模糊搜索',
      },
      fieldName: 'template_no',
      label: '简码',
      operator: 'false',
    },
    {
      component: 'ApiSelect',
      componentProps: () => {
        return {
          api: fetchgetFactoryIndex,
          // 禁止本地过滤
          filterOption: false,
          notFoundContent: fetching.value ? undefined : null,
          // 搜索词变化时记录下来， 使用useDebounceFn防抖。
          onSearch: useDebounceFn((value: string) => {
            keyword4.value = value
          }, 300),
          // 远程搜索参数。当搜索词变化时，params也会更新
          params: {
            keyword: keyword4.value || undefined,
          },
          showSearch: true,
          allowClear: true,
        }
      },
      fieldName: 'supply_id',
      operator: '=',

      label: '供货商',
      renderComponentContent: () => {
        return {
          notFoundContent: fetching.value ? h(Spin) : undefined,
        }
      },
    },
    {
      component: 'ApiSelect',
      componentProps: () => {
        return {
          api: fetgetWareHouse,
          // 禁止本地过滤
          filterOption: false,
          notFoundContent: fetching.value ? undefined : null,
          // 搜索词变化时记录下来， 使用useDebounceFn防抖。
          onSearch: useDebounceFn((value: string) => {
            keyword.value = value
          }, 300),
          // 远程搜索参数。当搜索词变化时，params也会更新
          params: {
            keyword: keyword.value || undefined,
          },
          showSearch: true,
          allowClear: true,
        }
      },
      fieldName: 'warehouse_id',
      label: '仓库',
      operator: '=',
      renderComponentContent: () => {
        return {
          notFoundContent: fetching.value ? h(Spin) : undefined,
        }
      },
    },
    {
      component: 'Select',
      componentProps: {
        allowClear: true,
        filterOption: true,
        options: [
          {
            label: '成品#首单',
            value: '8',
          },
          {
            label: '加工#补单',
            value: '9',
          },
          {
            label: '加工#首单',
            value: '10',
          },
          {
            label: '成品#补单',
            value: '11',
          },
          {
            label: '成品#加单',
            value: '12',
          },
          {
            label: '加工#加单',
            value: '13',
          },
          {
            label: '待买手拆分',
            value: '99',
          },
        ],
        showSearch: true,
        operator: '123',
      },
      fieldName: 'purchase_type',
      operator: '=',
      label: '采购性质',
    },
    {
      component: 'RangePicker',
      componentProps: {
        // 让占位文字更明显
        placeholder: ['开始时间', '结束时间'],
        style: { width: '100%' },
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
      fieldName: 'purchase_date',
      operator: 'RANGE',
      label: '采购日期',
    },
    {
      component: 'Select',
      componentProps: {
        allowClear: true,
        filterOption: true,
        options: [
          {
            label: '已完成',
            value: 1,
          },
          {
            label: '未完成',
            value: 0,
          },
        ],
        showSearch: true,
      },
      fieldName: 'is_completed_warehouse',
      operator: '=',
      label: '分仓审核',
    },
    {
      component: 'Select',
      componentProps: {
        allowClear: true,
        mode: 'multiple',
        options: [
          {
            label: '已完成',
            value: 1,
          },
          {
            label: '未完成',
            value: 0,
          },
          {
            label: '部分完成',
            value: 2,
          },
        ],
        showSearch: true,
      },
      fieldName: 'is_completed',
      operator: 'rangeIn',
      render: 'tag',
      label: '是否完成',
    },
    {
      component: 'Select',
      componentProps: {
        allowClear: true,
        filterOption: true,
        options: [
          {
            label: '中止',
            value: 1,
          },
          {
            label: '正常',
            value: 0,
          },
        ],
        placeholder: '单据状态',
        showSearch: true,
      },
      fieldName: 'is_stop',
      operator: '=',
      label: '单据状态',
    },
    {
      component: 'Select',
      componentProps: {
        allowClear: true,
        filterOption: true,
        options: [
          {
            label: '未审核',
            value: 0,
          },
          {
            label: '已审核',
            value: 1,
          },
        ],
        showSearch: true,
      },
      fieldName: 'posted',
      render: 'tag',
      operator: '123',
      label: '审核状态',
    },
    {
      component: 'Select',
      componentProps: {
        allowClear: true,
        filterOption: true,
        options: [
          {
            label: '未标记',
            value: 0,
          },
          {
            label: '已标记',
            value: 1,
          },
        ],
        showSearch: true,
        operator: '123',
      },
      fieldName: 'is_cw_sign',
      operator: 'LIKE',
      label: '标记状态',
    },
    {
      component: 'RangePicker',
      componentProps: {
        // 让占位文字更明显
        placeholder: ['开始时间', '结束时间'],
        style: { width: '100%' },
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
      },
      fieldName: 'cw_sign_time',
      operator: 'RANGE',
      label: '财务标记/取消时间',
    },
    {
      component: 'RangePicker',
      componentProps: {
        // 让占位文字更明显
        placeholder: ['开始时间', '结束时间'],
        style: { width: '100%' },
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
      },
      fieldName: 'completed_time',
      operator: 'RANGE',
      label: '完结时间',
    },
    {
      component: 'Select',
      componentProps: {
        allowClear: true,
        filterOption: true,
        options: [
          {
            label: '未上传',
            value: 0,
          },
          {
            label: '已上传',
            value: 1,
          },
        ],
        showSearch: true,
      },
      label: '是否上传附件',
      fieldName: 'isUploadFile',
      operator: 'false',
    },
  ],
  // 是否可展开
  showCollapseButton: true,
  submitButtonOptions: {
    content: '查询',
  },
}
const searchValue:any =ref([])
const gridOptions: VxeTableGridOptions = {
  checkboxConfig: {
    highlight: true,
    labelField: 'name',
    trigger:'row',
  },
  height: 'auto',
  columns: [
    {
      type: 'checkbox', // 多选列（自带全选框）
      width: 50, // 列宽
      align: 'center', // 居中
      fixed: 'left', // 固定在最左侧
      title: '', // 表头文字
    },
    {
      field: 'goods_purchase_id',
      title: '序号',
      width: 80,
    },
    { title: '采购单号', field: 'goods_purchase_sn', width: 110 },
    { field: 'supply_name', sortable: true, title: '供应商', width: 200 },
    { field: 'goods_no', sortable: true, title: '货号', width: 120 },
    {
      field: 'template_no',

      title: '简码',
      width: 100,
    },
    {
      title: '数量',
      field: 'total_num',
      width: 80,
    },
    {
      title: '收货仓库',
      field: 'warehouse_name',
      width: 210,
    },
    {
      title: '采购性质',
      field: 'purchase_type',
      width: 120,

      slots: { default: 'purchase_type' },
    },
    {
      title: '成分',
      field: 'component',
      width: 100,
    },
    { title: '采购日期', field: 'purchase_date', width: 100 },
    {
      title: '是否完成',
      field: 'is_completed',
      width: 80,
      cellRender: {
        name: 'CellTag',
        options: [
          {
            color: 'success',
            label: '完成',
            value: 1,
          },
          { color: 'error', label: '未完成', value: 0 },
        ],
      },
    },
    {
      field: 'is_stop',
      title: '单据状态',
      width: 80,
      cellRender: {
        name: 'CellTag',
        options: [
          {
            color: 'success',
            label: '正常',
            value: 0,
          },
          { color: 'error', label: '中止', value: 1 },
        ],
      },
    },
    { title: '货品分类', field: 'category_name', width: 100 },
    {
      title: '标记状态',
      field: 'is_cw_sign',
      width: 80,
      cellRender: {
        name: 'CellTag',
        options: [
          {
            color: 'success',
            label: '已标记',
            value: 1,
          },
          { color: 'error', label: '未标记', value: 0 },
        ],
      },
    },

    { title: '财务标记/取消时间', field: 'cw_sign_time', width: 150 },
    { title: '备注', field: 'remark', width: 70 },
    { title: '完结时间', field: 'completed_time', width: 100 },
    { title: '创建', field: 'created', width: 150 },
    { title: '更新', field: 'last_audit', width: 150 },
    {
      title: '审核',
      field: 'complete_price',
      width: 100,
    },
    { title: 'XO单', field: 'source_order_code', width: 140 },
    {
      title: 'JH单',
      field: 'aef_jh_code',
      width: 100,
    },
    { title: 'PO单', field: 'aef_order_code', width: 100 },
    {
      title: '是否上传附件',
      field: 'isUploadFile',
      width: 100,
      cellRender: {
        name: 'CellTag',
        options: [
          {
            color: 'success',
            label: '已上传',
            value: 1,
          },
          { color: 'error', label: '未上传', value: 0 },
        ],
      },
    },
    {
      field: 'action',
      title: '操作',
      fixed: 'right',
      width: 80,
      slots: { default: 'action' },
    },
  ],
  exportConfig: {},
  keepSource: true,
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        const search: any[] = []
        for (const [key, value] of Object.entries(formValues)) {
          if (value === null || value === '' || value === undefined) continue
          const fieldSchema = formOptions.schema.find((i: any) => i.fieldName === key)
          // 处理特殊字段格式
          let fieldValue = value
          if (key === 'cw_sign_time' && Array.isArray(value) && value.length === 2) {
            // 将日期范围数组转换为字符串格式："开始时间,结束时间"
            fieldValue = value.join(',')
          }
          if (key === 'purchase_date' && Array.isArray(value) && value.length === 2) {
            // 将日期范围数组转换为字符串格式："开始时间,结束时间"
            fieldValue = value.join(',')
          }
          if (key === 'time_category') {
            fieldValue = completePaths(value, timeCategoryOptions.value)
          }
          if (key === 'category') {
            fieldValue = completeCategoryPaths(value, categoryOptions.value)
          }
          search.push({
            field: key,
            val: fieldValue,
            operator: fieldSchema?.operator,
            render: fieldSchema?.render,
          })
        }
        searchValue.value = search
        const res = await getGoodsPurchaseList({
          page: page.currentPage,
          limit: page.pageSize,
          search,
          order: 'purchase_date,desc',
          tableSize: 'small',
        })

        return { items: res.list, total: res.total }
      },
    },
    sort: true,
  },
  id: 'goods_purchase',
  customConfig: {
    storage: true,
  },
  toolbarConfig: {
    search: true,
    custom: true,
    export: true,
    // import: true,
    refresh: true,
    zoom: true,
  },
  rowClassName({ row }) {
    // 如果posted ==0 就是红色字体
    return row.posted === 0 ? 'text-red-500' : ''
  },
}

onMounted(async () => {
  const cateRes = await allIndex()
  categoryOptions.value = cateRes.list
  const timeRes = await getTreeAll()
  timeCategoryOptions.value = timeRes
})

// 双击打开编辑
const gridEvents: VxeGridListeners = {
  cellDblclick: ({ row }) => {
    openEdit(row, 'edit')
  },
}
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions, gridEvents })

//  按钮的禁用状态
const isDisabled = ref(true)
const isFinancialMarkDisabled = ref(true)
const isFinancialUnmarkDisabled = ref(true)
const isClearJhCodeDisabled = ref(true)
const isApprovalDisabled = ref(true)
const isDeleteDisabled = ref(true)

// 检查并更新拷贝按钮状态
function checkCopyButtonStatus() {
  try {
    if (gridApi?.grid?.getCheckboxRecords) {
      const selectedRecords = gridApi.grid.getCheckboxRecords()
      // 检查是否包含已财务标记的记录
      const hasFinancialMark = selectedRecords.some((record) => record.is_cw_sign === 1)
      const hasUnmarkedFinancial = selectedRecords.some((record) => record.is_cw_sign === 0)
      isDisabled.value = !selectedRecords || selectedRecords.length === 0
      isFinancialMarkDisabled.value = !selectedRecords || selectedRecords.length === 0 || hasFinancialMark
      isFinancialUnmarkDisabled.value = !selectedRecords || selectedRecords.length === 0 || hasUnmarkedFinancial

      const hasEmptySourceOrderCode = selectedRecords.some((record) => record.source_order_code === undefined || record.source_order_code === null || record.source_order_code === '')
      isClearJhCodeDisabled.value = !selectedRecords || selectedRecords.length === 0 || hasEmptySourceOrderCode

      const hasApprovalCondition = selectedRecords.some(
        (post) =>
          (post.posted !== undefined && post.post_time !== undefined && post.post_time == null) || // 单据
          post.Posted == 0 ||
          (post.posted !== undefined && post.post_time !== undefined && post.post_time == 0) ||
          (post.posted !== undefined && post.posted == 0) ||
          (post.state !== undefined && post.state == 10)
      )

      isApprovalDisabled.value = !hasApprovalCondition

      // 删除按钮禁用逻辑 - 示例逻辑，需根据实际业务规则调整
      isDeleteDisabled.value = !selectedRecords || selectedRecords.length === 0 || !hasApprovalCondition
    } else {
      isDisabled.value = true
      isFinancialUnmarkDisabled.value = true
      isFinancialMarkDisabled.value = true
      isClearJhCodeDisabled.value = true
      isApprovalDisabled.value = true
      isDeleteDisabled.value = true
    }
  } catch {
    isDisabled.value = true
    isFinancialUnmarkDisabled.value = true
    isFinancialMarkDisabled.value = true
    isClearJhCodeDisabled.value = true
    isApprovalDisabled.value = true
  }
}

// 使用watch监听gridApi的变化
watch(
  () => gridApi?.grid,
  (newGrid) => {
    if (newGrid) {
      // 当grid可用时，立即检查一次状态
      checkCopyButtonStatus()
      // 设置一个定时器定期检查选中状态变化
      const interval = setInterval(() => {
        if (gridApi?.grid) {
          checkCopyButtonStatus()
        }
      }, 300) // 每300ms检查一次
      // 组件卸载时清除定时器
      onUnmounted(() => {
        clearInterval(interval)
      })
    }
  },
  { immediate: true }
)

const [delModal, delModalApi] = useVbenModal({
  connectedComponent: deleteDialog,
})
// 删除
function delRow() {
  delModalApi
    .setData({
      rowData: gridApi.grid.getCheckboxRecords(),
    })
    .open()
}
// 审核
function approvalBut() {
  const data = gridApi.grid.getCheckboxRecords()

  const ids = data.map((record: any) => record.goods_purchase_id)
  approval({ ids, is_confirm_ware: 0 }).then((res: any) => {
    if (res.data.code !== 1) {
      message.error(res.data.msg)
      return
    }
    gridApi.reload()
    message.success('审核成功')
  })
}

function againstShow() {
  const data = gridApi.grid.getCheckboxRecords()
  let is_have_posted_data = false
  data.forEach((item, index) => {
    if (item.posted == 0 && item.post_time == 0) {
      is_have_posted_data = true
    }
  })
  if (is_have_posted_data) {
    message.error('存在未审核的数据，无法反审')
    return false
  } else {
    const againtData = data.map((item) => ({
      goods_purchase_id: item.goods_purchase_id,
      goods_purchase_sn: item.goods_purchase_sn,
    }))
    handleAgainstNew(againtData)
  }
}

// 标记完成
function mark_over() {
  AntModal.confirm({
    title: '提示',
    content: '确认是否要完成大货采购单',
    okText: '是',
    cancelText: '否',
    onOk() {
      const data = gridApi.grid.getCheckboxRecords()
      const sel_id_arr: any = []
      data.forEach((item, index) => {
        if (item.is_completed != 1) {
          sel_id_arr.push(item.goods_purchase_id)
        }
      })
      if (sel_id_arr.length === 0) {
        message.error('该订单已全部标记完成')
        return
      }

      markComplete({
        id_arr: sel_id_arr,
        is_completed: 1,
      }).then((res: any) => {
        gridApi.reload()
        if (res.data.code === 1) {
          message.success(res.data.msg)
        } else {
          message.error(res.data.msg)
        }
      })
    },
    onCancel() {},
  })
}
// 中止
function stop_purchase() {
  const data = gridApi.grid.getCheckboxRecords()
  const sel_id_arr: any = []
  data.forEach((item, index) => {
    sel_id_arr.push(item.goods_purchase_id)
  })
  markStop({
    id_arr: sel_id_arr,
  }).then((res: any) => {
    gridApi.reload()
    if (res.data.code === 1) {
      message.success(res.data.msg)
    } else {
      message.error(res.data.msg)
    }
  })
}

function sign(type: string) {
  const textArr: any = []
  textArr.success = '标记完结'
  textArr.error = '反标记完结'
  textArr.clear_jh_code = '清空计划单'
  const text = textArr[type] || '未知'
  AntModal.confirm({
    title: '提示',
    content: `确定要${text}吗？`,
    okText: '是',
    cancelText: '否',
    onOk() {
      const data = gridApi.grid.getCheckboxRecords()
      const params = data.map((item: any) => item.goods_purchase_id)
      requestClient.post('admin/GoodsPurchase/sign', { ids: params, type }, { responseReturn: 'raw' }).then((res: any) => {
        gridApi.reload()
        if (res.data.code === 1) {
          message.success(res.data.msg)
        } else {
          message.error(res.data.msg)
        }
      })
    },
    onCancel() {},
  })
}

const [againstDialogModal, againstDialogModalApi] = useVbenModal({
  connectedComponent: againstDialog,
  destroyOnClose: true,
})

function handleAgainstNew(sel_arr: any) {
  againstDialogModalApi.setData({ data: sel_arr }).open()
}

function modelClose() {
  gridApi.reload()
}

const [formModal, formModalApi] = useVbenModal({
  connectedComponent: popupForm,
})
// 编辑
function openEdit(res: any, but: any) {
  formModalApi
    .setData({
      rowData: res,
      view: but,
    })
    .open()
}

// 导出合同
const [exportContractModal, exportContractModalApi] = useVbenModal({
  connectedComponent: exportContract,
})

function openContractModalApi() {
  const data = gridApi.grid.getCheckboxRecords()
  const ids = data.map((item: any) => item.goods_purchase_id)
  exportContractModalApi.setData({ id: ids }).open()
}

// 合同管理
const [fileManageModal, fileManageModalApi] = useVbenModal({
  connectedComponent: fileManage,
})

function openFileModal() {
  const data = gridApi.grid.getCheckboxRecords()
  const ids = data.map((item: any) => item.goods_purchase_id)
  fileManageModalApi.setData({ data: ids, type: '2',search: searchValue.value }).open()
}
</script>

<template>
  <Page auto-content-height>
    <Grid>
      <template #toolbar-actions>
        <div>
          <Space>
            <Button type="primary" @click="openEdit('', 'add')">新建</Button>
            <Button type="primary" danger :disabled="isDeleteDisabled" title="删除选中行" @click="delRow">删除</Button>
            <template v-if="!isApprovalDisabled">
              <Popconfirm title="确定审核选中记录" ok-text="确认" cancel-text="取消" @confirm="approvalBut()">
                <Button type="primary" class="my-green-btn" title="审核选中行" :disabled="isApprovalDisabled">审核</Button>
              </Popconfirm>
            </template>
            <template v-else>
              <Button type="primary" class="my-green-btn" title="审核选中行" disabled>审核</Button>
            </template>
            <Button type="primary" danger :disabled="isDisabled" @click="againstShow()">反审</Button>
            <Button type="primary" :disabled="isDisabled" @click="mark_over()">标记完成</Button>
            <Button type="primary" danger :disabled="isDisabled" @click="stop_purchase">中止</Button>
            <Button type="primary" :disabled="isFinancialMarkDisabled" @click="sign('success')">财务标记</Button>
            <Button type="primary" danger :disabled="isFinancialUnmarkDisabled" @click="sign('error')">财务反标记</Button>
            <Button type="primary" danger :disabled="isClearJhCodeDisabled" @click="sign('clear_jh_code')">清空阿尔法计划单号（重新同步）</Button>
            <Button type="primary" class="my-green-btn" :disabled="isDisabled" @click="openContractModalApi">导出合同 new</Button>
            <Button type="primary" class="my-green-btn" @click="openFileModal()">附件管理与导出</Button>
          </Space>
        </div>
      </template>
      <!-- 操作列插槽 -->
      <template #erp_id="{ row }">
        <Tag v-if="row.goods?.erp_id > 0" color="green">已推送</Tag>
        <Tag v-else color="red">未推送</Tag>
      </template>
      <template #posted="{ row }">
        <Tag v-if="row.goodsPurchase?.posted > 0" color="green">已审核</Tag>
        <Tag v-else color="red">未审核</Tag>
      </template>
      <template #purchase_type="{ row }">
        <Tag v-if="row.purchase_type === 8" color="green">成品#首单</Tag>
        <Tag v-else-if="row.purchase_type === 9" color="red">加工#补单</Tag>
        <Tag v-else-if="row.purchase_type === 10" color="blue">加工#首单</Tag>
        <Tag v-else-if="row.purchase_type === 11" color="blue">成品#补单</Tag>
        <Tag v-else-if="row.purchase_type === 12" color="blue">成品#加单</Tag>
        <Tag v-else-if="row.purchase_type === 13" color="blue">加工#加单</Tag>
        <Tag v-else-if="row.purchase_type === 99" color="blue">待买手拆分</Tag>
      </template>

      <!-- 操作列插槽 -->
      <template #action="{ row }">
        <Space>
          <Button type="primary" size="small" @click="openEdit(row, 'edit')">编辑</Button>
        </Space>
      </template>
    </Grid>
    <delModal @close="modelClose()" />
    <formModal @close="modelClose()" />
    <againstDialogModal @close="modelClose()" />
    <exportContractModal />
    <fileManageModal @close="modelClose()" />
  </Page>
</template>
<style lang="scss" scoped>
.my-green-btn.ant-btn-primary {
  background-color: #67c23a;
  border-color: #67c23a;
}

.my-yello-btn.ant-btn-primary {
  background-color: #e6a23c;
  border-color: #e6a23c;
}
</style>
